package com.hmall.search.config;

import org.apache.http.HttpHost;
import org.apache.http.client.config.RequestConfig;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestClientBuilder;
import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author: suren@517na.com
 * @CreateTime: 2025-04-07
 * @Description: 配置类
 */

@Configuration
public class SearchConfig {
    @Bean
    public RestHighLevelClient restHighLevelClient() {
        return new RestHighLevelClient(RestClient.builder(
                HttpHost.create("http://192.168.152.101:9200")
        ).setRequestConfigCallback(builder -> {
            builder.setConnectTimeout(300000);
            builder.setSocketTimeout(300000);
            builder.setConnectionRequestTimeout(30000);
            return builder;
        }));
    }

}
